<template>
	<view >
		<view >
		
			<view class="afim_main" v-for="(item, i) in dataList" :key="i" @click="onClickItem(item)">
				<view class="img-box">
					<text class="tip-text-blue">去验收</text>
					<image class="list-img" src="@/static/img/default.png" v-if="item.pics.length == 0"></image>
					<image class="list-img" :src="fileUrl + item.pics[0].pic_url" v-if="item.pics.length > 0"></image>
				</view>
				
				<view class="afim_le">
					<view class="afim_list">
						<label>检修设备:</label>
						<text>{{item.device_name}}</text>
					</view>
					<view class="afim_list">
						<label>检修票号:</label>
						<text>{{item.overhaul_no}}</text>
					</view>
					<view class="afim_list">
						<label>主修人员:</label>
						<text>{{item.major_name}}</text>
					</view>
					<view class="afim_list">
						<label>值班工艺:</label>
						<text>{{item.duty_user}}</text>
					</view>
					<view class="afim_list">
						<label>检修时间:</label>
						<text>{{item.overhaul_date}}</text>
					</view>
				</view>
			</view>
		</view>
		<empty v-if="dataList.length == 0"></empty>
	</view>
</template>

<script>
	import {FILE_URL, queryOverhaulVerifyList} from '@/api/maintenance/selfs.js'
	import Empty from '@/components/selfs/Empty.vue'
	export default {
		components: {
			Empty
		},
		data() {
			return {
				userName: '',
				userId: '',
				deptName: '',
				deptId: '',
				dataList: [],
				fileUrl: FILE_URL
			}
		},
		methods: {
			onClickTab(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
					this.fetchData()
				}
			
			},
			onClickItem(item) {
				uni.navigateTo({
					url: './final_accept?userId=' + this.userId + '&userName=' + this.userName
						+ '&deptId=' + this.deptId + '&deptName=' + this.deptName + '&overhaul_id=' 
						+ item.overhaul_id + '&plan_id=' + item.plan_id + '&is_bidding=' + item.is_bidding
					})
			},
			fetchData() {
				let params
				params = {type: 2, user_id: this.userId, dept_id: this.deptId}
				uni.showLoading({
					title: '正在查询...'
				})
				queryOverhaulVerifyList(params).then(res => {
					this.dataList = res.datas
				})
			}
		},
		onLoad:function(e){
			this.userName = e.userName
			this.userId = e.userId
			this.deptName = e.deptName
			this.deptId = e.deptId
			this.fetchData()
		},
		created:function(){
			// 订阅详情页回传值的监听
			uni.$on("final_accept_refresh", (val)=>{
				this.fetchData()
			})
		},
		beforeDestroy:function() {
		    uni.$off('final_accept_refresh')
		},
	}
</script>

<style>
	page{
		background: #F4F4F4;
	}
	.ware_main{
		width: 100%;
		margin: 0 auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #ffffff;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 1;
	}
	.ware_le{
		width: 100%;
	}
	.afim_main{
		margin: 15upx;
		display: flex;
		justify-content: center;
		background: #FFFFFF;
		border-bottom: 1upx solid #F4F4F4;
		padding: 10upx;
		border-radius: 10upx;
	}
	.afim_le{
		width: 70%;
	}
	.afim_list{
		margin: 0upx auto;
	}
	.afim_le label{
		color: #267DFF;
		font-size: 30upx;
	}
	.afim_le text{
		font-size: 30upx;
		padding-left: 20upx;
	}
	.afim_ri text{
		border: 2upx solid #267DFF;
		color: #267DFF;
		padding: 3upx 16upx;
		border-radius: 10upx;
		font-size: 30upx;
	}
	.afim_ri text:active{
		background: #267DFF;
		color: #FFFFFF;
	}
	.img-box {
 flex: 0 0 auto;
 width: 170rpx;
 height: 170rpx;
 padding: 15rpx;
 position: relative;
}

.list-img {
	width: 100%;
	height: 100%;
}
	.tip-text-blue {
		font-size: 28rpx;
		background-color: #007AFF;
		color: #fff;
		padding: 5rpx 10rpx;
		border-radius: 2rpx;
	}
	.tip-text-red {
		font-size: 28rpx;
		background-color: #ff0000;
		color: #fff;
		padding: 5rpx 10rpx;
		border-radius: 2rpx;
	}
	.tip-text-green {
		font-size: 28rpx;
		background-color: #00cf00;
		color: #fff;
		padding: 5rpx 10rpx;
		border-radius: 2rpx;
	}
</style>
